//
//  BHBottomViewButton.m
//  Behing
//
//  Created by Lj on 2017/10/20.
//  Copyright © 2017年 lj. All rights reserved.
//

#import "BHBottomViewButton.h"

@interface BHBottomViewButton ()
@property (nonatomic, strong) BHSingleButton* singleButton;
@property (nonatomic, strong) UIView *backView;

@end

@implementation BHBottomViewButton

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor clearColor];
        [self setUpUI];
    }
    return self;
}

- (void)setButtonName:(NSString *)buttonName {
    self.singleButton.button_name(buttonName);
}

- (void)setUpUI {
    self.backView = [[UIView alloc]init];
    self.backView.frame = CGRectMake(25, App_Frame_Width - 50, 36, 36);
    self.backView.layer.cornerRadius = 18;
    self.backView.layer.shadowOpacity = 0.5f;
    self.backView.layer.shadowOffset = CGSizeMake(3.0f, 3.0f);
    self.backView.layer.shadowRadius = 5.0f;
    self.backView.layer.shadowColor=[[UIColor grayColor] colorWithAlphaComponent:0.8].CGColor;
    [self addSubview:self.backView];
    
    self.singleButton = [[BHSingleButton alloc]init];
    self.singleButton.button_title_color([UIColor whiteColor]);
    [self.singleButton addTarget:self action:@selector(donationsClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.singleButton];
    [self.singleButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(25);
        make.left.equalTo(self).offset(25);
        make.height.offset(40);
        make.width.offset(App_Frame_Width - 50);
    }];
}

- (void)donationsClick:(UIButton *)sender {
    if (self.block) {
        self.block();
    }
}

- (void)getButtonUIView:(void(^)(BHSingleButton *button))block {
    if (self.singleButton) {
        block(self.singleButton);
    }
}


@end
